#include "pow.h"

double MyPowNF(double x,int n)
{
  double res = 1;
  int i = 0;
  for(i = n;i!=0;i/=2)
  {
    if(i % 2 != 0) res *= x;

    x *= x;
  }

  return n<0 ? 1/res : res;
}


double _MyPowF(double x,int n)
{
    if(n == 0) return 1;
    double y = _MyPowF(x,n/2);
    return n % 2 == 0 ? y*y :y*y*x;
}


double MyPowF(double x, int n){
    return n<0 ? 1/_MyPowF(x,n) : _MyPowF(x,n);
}



